package hos.okgo;

import com.lzy.okgo.convert.Converter;
import com.lzy.okgo.request.DeleteRequest;
import com.lzy.okgo.request.GetRequest;
import com.lzy.okgo.request.HeadRequest;
import com.lzy.okgo.request.OptionsRequest;
import com.lzy.okgo.request.PatchRequest;
import com.lzy.okgo.request.PostRequest;
import com.lzy.okgo.request.PutRequest;
import com.lzy.okgo.request.TraceRequest;

import hos.okgo.adapter.CacheCall;

/**
 * <p>Title: OkGoExpand </p>
 * <p>Description:  </p>
 * <p>Company: www.mapuni.com </p>
 *
 * @author : 蔡俊峰
 * @version : 1.0
 * @date : 2023/2/20 13:55
 */
public class OkGoExpend {
    private static Converter<?> converter;

    @SuppressWarnings("unchecked")
    public static <T> Converter<T> getConverter() {
        return (Converter<T>) converter;
    }

    public static <T> void setConverter(Converter<T> converter) {
        OkGoExpend.converter = converter;
    }

    /**
     * get请求
     */
    public static <T> GetRequest<T> get(String url) {
        GetRequest<T> request = new GetRequest<T>(url);
        return request.call(new CacheCall<T>(request));
    }

    /**
     * post请求
     */
    public static <T> PostRequest<T> post(String url) {
        PostRequest<T> request = new PostRequest<T>(url);
        return request.call(new CacheCall<T>(request));
    }

    /**
     * put请求
     */
    public static <T> PutRequest<T> put(String url) {
        PutRequest<T> request = new PutRequest<T>(url);
        return request.call(new CacheCall<T>(request));
    }

    /**
     * head请求
     */
    public static <T> HeadRequest<T> head(String url) {
        HeadRequest<T> request = new HeadRequest<T>(url);
        return request.call(new CacheCall<T>(request));
    }

    /**
     * delete请求
     */
    public static <T> DeleteRequest<T> delete(String url) {
        DeleteRequest<T> request = new DeleteRequest<T>(url);
        return request.call(new CacheCall<T>(request));
    }

    /**
     * options请求
     */
    public static <T> OptionsRequest<T> options(String url) {
        OptionsRequest<T> request = new OptionsRequest<T>(url);
        return request.call(new CacheCall<T>(request));
    }

    /**
     * patch请求
     */
    public static <T> PatchRequest<T> patch(String url) {
        PatchRequest<T> request = new PatchRequest<T>(url);
        return request.call(new CacheCall<T>(request));
    }

    /**
     * trace请求
     */
    public static <T> TraceRequest<T> trace(String url) {
        TraceRequest<T> request = new TraceRequest<T>(url);
        return request.call(new CacheCall<T>(request));
    }

}
